package codeTop;

public class q226 {
    public TreeNode invertTree(TreeNode root) {
        dfs(root);
        return root;
    }
    void dfs(TreeNode node){
        if (node == null) {
            return;
        }
        TreeNode right = node.right;
        node.right = node.left;
        node.left = right;
        dfs(node.right);
        dfs(node.left);
    }
}
